﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>用户管理</title>
    <!--引入 element-ui 的样式，-->
    <link rel="stylesheet" href="../../assets/css/elementui.css">
    <style>
        [v-cloak] {
            display: none;
        }

        .el-row .el-form-item {
            margin-bottom: 0px;
            text-align: center;
        }

        .el-row .el-col {
            border-right: 1px solid black;
        }

        .el-row {
            border: 1px solid black;
            margin-bottom: -1px !important;
        }

        .info {
            text-align: left !important;
        }
    </style>
</head>
<body>
<!-- 正文开始 -->
<div id="app" v-cloak>
    <el-form inline="true" :model="searchForm" label-width="80px">
        <el-form-item label="身份证">
            <el-input v-model="searchForm.idNum" placeholder="身份证"></el-input>
        </el-form-item>
        <el-form-item label="员工姓名">
            <el-input v-model="searchForm.name" placeholder="员工姓名"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="search">查询</el-button>
        </el-form-item>
    </el-form>
    <el-card>
        <el-table
                :data="tableData"
                border
                style="width: 100%">
            <el-table-column
                    prop="name"
                    width="180"
                    label="姓名">
            </el-table-column>
            <el-table-column
                    prop="idNum"
                    width="180"
                    label="身份证号">
            </el-table-column>
            <el-table-column
                    prop="sex"
                    label="性别"
                    width="180">
                <template slot-scope="scope">
                    {{ scope.row.sex=='1'?'男':'女' }}
                </template>
            </el-table-column>
            <el-table-column
                    prop="status"
                    label="状态"
                    width="180">
                <template slot-scope="scope">
                    <el-button size="mini" type="warning" @click="changeStatus(scope.row)">
                        {{scope.row.lock==1?'已锁定':'未锁定'}}
                    </el-button>
                </template>
            </el-table-column>
            <el-table-column
                    label="操作"
                    width="250">
                <template slot-scope="scope">
                    <el-button @click="handleEdit(scope.row)" type="text" size="small">详情</el-button>
                    <el-button @click="handleHire(scope.row)" type="text" size="small"
                               v-if="scope.row.lock==1&&scope.row.healthPdf&&scope.row.healthPfd!=''">
                        录用审批
                    </el-button>
                    <el-button @click="handleNewTrain(scope.row)" type="text" size="small"
                               v-if="scope.row.lock==1&&scope.row.healthPdf&&scope.row.healthPfd!=''">
                        培训审批
                    </el-button>
                    <el-button @click="handleContract(scope.row)" type="text" size="small"
                               v-if="scope.row.lock==1&&scope.row.healthPdf&&scope.row.healthPfd!=''">
                        入职合同
                    </el-button>
                </template>
            </el-table-column>

        </el-table>
        <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page.sync="page.currentPage"
                :page-size="page.rows"
                layout="total, sizes, prev, pager, next"
                :page-sizes="[10, 20, 50]"
                :total="page.total">
        </el-pagination>
    </el-card>
    <!--员工登记表-->
    <el-dialog
            title="员工登记表"
            :visible.sync="dialogVisible"
            width="80%"
            :before-close="handleClose">
        <el-form>
            <el-row>
                <el-col span="20">
                    <el-row>
                        <el-col :span="3">
                            <el-form-item>姓名</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.name"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>性别</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-select v-model="currentRow.sex" placeholder="请选择">
                                    <el-option v-for="item in sexOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>出生年月</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.birthTime"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>政治面貌</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.political"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="3">
                            <el-form-item>籍贯</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.homeTown"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>文化程度</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-select v-model="currentRow.edu" placeholder="请选择">
                                    <el-option v-for="item in eduOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>健康状况</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.health"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>重大疾病史</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.sick"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                    <el-row>
                        <el-col :span="3">
                            <el-form-item>婚否</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-select v-model="currentRow.single" placeholder="请选择">
                                    <el-option v-for="item in singleOption" :key="item.value" :label="item.label"
                                               :value="item.value">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>联系电话</el-form-item>
                        </el-col>
                        <el-col :span="3">
                            <el-form-item>
                                <el-input v-model="currentRow.phone"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>紧急情况联系人电话</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>
                                <el-input v-model="currentRow.warnPhone"></el-input>
                            </el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
                <el-col span="4"></el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>身份证号</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.idNum"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>家庭住址</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.livePlace"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="5">
                    <el-form-item>户口所在地</el-form-item>
                </el-col>
                <el-col :span="19">
                    <el-form-item>
                        <el-input v-model="currentRow.idPlace"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="10">
                    <el-form-item>所获经济、行政或法律处罚情况</el-form-item>
                </el-col>
                <el-col :span="14">
                    <el-form-item>
                        <el-input type="textarea" v-model="currentRow.punish"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item>家庭主要成员及社会关系</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-row>
                        <el-col :span="6">
                            <el-form-item>称谓</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>称谓</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>工作单位及职业</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>联系方式</el-form-item>
                        </el-col>
                    </el-row>
                    <el-row v-for="(item,i) in relationList" :key="i">
                        <el-col :span="6">
                            <el-form-item>{{item.label}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.name}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.job}}</el-form-item>
                        </el-col>
                        <el-col :span="6">
                            <el-form-item>{{item.phone}}</el-form-item>
                        </el-col>
                    </el-row>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item style="text-align: left">学习经历（从最高学历开始填写）</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-row>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">学校/学院名称</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">起止年月</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">专业及所获文凭</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">证明人</el-form-item>
                    </el-col>
                </el-row>
                <el-row v-for="(item,i) in eduList" :key="i">
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.schoolName}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.startTime}}-{{item.endTime}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.major}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.confirmName}}</el-form-item>
                    </el-col>
                </el-row>
            </el-row>
            <el-row>
                <el-col :span="12">
                    <el-form-item style="text-align: left">参加过学校或何种技术培训班，获何证书（若没有，请注明无）</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item style="text-align: left">
                        <el-form-item>
                            <el-input type="textarea"
                                      v-model="skillListStr"
                                      :rows="3"></el-input>
                        </el-form-item>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">
                    <el-form-item style="text-align: left">工作经历（按时间顺序填写，必须填写应聘前工作单位）</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-row>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">单位名称</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">起止年月</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">离职原因</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">证明人</el-form-item>
                    </el-col>
                </el-row>
                <el-row v-for="(item,i) in workList" :key="i">
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.company}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.startTime}}-{{item.endTime}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.leaveReason}}</el-form-item>
                    </el-col>
                    <el-col :span="6">
                        <el-form-item style="text-align: left">{{item.confirmName}}</el-form-item>
                    </el-col>
                </el-row>
            </el-row>
            <el-row>
                <p>
                    本人声明：本人以上所述均属事实，未有任何虚假陈述，未有任何重大隐瞒，否则由此引起的任何法律和经济责任由本人承担。以上信息如有变更本人将及时通知单位，否则本人愿承担一切责任
                </p>
                <div style="float: right">{{dateFormatter(currentRow.upTime)}}</div>
            </el-row>
            <el-row>
                <el-col :span="10">
                    <el-form-item>健康审查表</el-form-item>
                </el-col>
                <el-col :span="14">
                    <el-form-item v-if="currentRow.healthPdf&&currentRow.healthPdf!=''">
                        <el-button @click="viewHealthPdf" type="primary">点击查看健康表</el-button>
                    </el-form-item>
                    <el-form-item v-else>
                        <div style="text-align: left;margin-left: 2em">
                            <el-button @click="chooseFile" type="primary">选择文件</el-button>
                            <span>{{fileName}}</span>
                        </div>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSaveHealthPdf" size="mini"
                       v-if="currentRow.healthPdf">确 定</el-button>
        </span>
    </el-dialog>
    <!--录用审批-->
    <el-dialog
            title="录用审批"
            :visible.sync="hireDialog"
            width="80%">
        <el-form>
            <el-row>
                <el-col :span="3">
                    <el-form-item>姓名</el-form-item>
                </el-col>
                <el-col :span="2">
                    <el-form-item>性别</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>出生年月</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>文化程度</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>婚否</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>录用部门</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>录用时间</el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>岗位</el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="2">
                    <el-form-item>
                        <el-select v-model="currentRow.sex" placeholder="请选择">
                            <el-option v-for="item in sexOption" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.birthTime"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-select v-model="currentRow.edu">
                            <el-option v-for="(item,i) in eduOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-select v-model="currentRow.single" placeholder="请选择">
                            <el-option v-for="item in singleOption" :key="item.value" :label="item.label"
                                       :value="item.value">
                            </el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.orgId" @change="handleOrgChange">
                            <el-option v-for="(item,i) in orgList" :key="i" :label="item.orgName"
                                       :value="item.orgId"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.hireTime"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="3">
                    <el-form-item>
                        <el-input v-model="currentRow.job"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="6">
                    <el-form-item>面试结论</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-form-item>
                        <el-input v-model="currentRow.audition" type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row v-for="(item,i) in hireApproveList" :key="i">
                <el-col :span="6">
                    <el-form-item>{{item[0].name}}</el-form-item>
                </el-col>
                <el-col :span="18">
                    <el-form-item>
                        <el-input readonly v-model="item[0].reason" type="textarea" autosize></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="hireDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSaveHire" v-if="currentRow.hireApprove!=1"
                       size="mini">确 定</el-button>
        </span>
    </el-dialog>
    <!--员工培训-->
    <el-dialog
            title="培训审批"
            :visible.sync="newTrainDialog"
            width="80%">
        <el-form>
            <el-row>
                <el-col :span="4">
                    <el-form-item>姓名</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.name"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>性别</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.sex">
                            <el-option v-for="(item,i) in sexOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>文化程度</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.edu">
                            <el-option v-for="(item,i) in eduOption" :key="i" :label="item.label"
                                       :value="item.value"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="4">
                    <el-form-item>录用部门</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-select v-model="currentRow.orgId" @change="handleOrgChange">
                            <el-option v-for="(item,i) in orgList" :key="i" :label="item.orgName"
                                       :value="item.orgId"></el-option>
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>入职时间</el-form-item>
                </el-col>

                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.hireTime"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>岗位</el-form-item>
                </el-col>
                <el-col :span="4">
                    <el-form-item>
                        <el-input v-model="currentRow.job"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="18">
                    <el-form-item>培训内容</el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>培训讲师</el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>企业文化</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行企业文化宣导培训</h5>
                        <p>公司简介：包含公司发展历史，目前状况等</p>
                        <p>企业文化：包含公司经营理念，核心价值观等</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-input readonly style="line-height: 8em"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>企业制度</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行企业管理制度宣读培训</h5>
                        <p>休息、休假、考勤制度，入离职制度，转正制度、奖惩制度、行为规范、工作纪律、合同、薪酬待遇、福利待遇、保密制度等</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-input readonly style="line-height: 8em"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>质量方针与意识</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <p>公司 质量方针的培训</p>
                        <p>公司质量意识的培训</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-input readonly style="line-height: 8em"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>安全教育培训</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <h5>进行现场规章知道胡和遵章守纪教育</h5>
                        <p>公司必须遵守的安全事项</p>
                        <p>现场内可能存在的不安全因素</p>
                        <p>现场安全生产制度、规定和安全注意事项</p>
                        <p>个人劳动防护用品及劳保用品的穿戴规范</p>
                        <p>职业卫生健康知识</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-input readonly style="line-height: 8em"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex">
                <el-col :span="6">
                    <el-form-item>岗位职责与权限</el-form-item>
                </el-col>
                <el-col :span="12">
                    <el-form-item class="info">
                        <p>岗位的职责</p>
                        <p>岗位的权限</p>
                    </el-form-item>
                </el-col>
                <el-col :span="6">
                    <el-form-item>
                        <el-input readonly style="line-height: 8em"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="hireDialog = false" size="mini">取 消</el-button>
            <el-button v-if="currentRow.trainApprove!=1" type="primary" @click="handleSaveNewTrain"
                       size="mini">确 定</el-button>
        </span>
    </el-dialog>
    <!--合同-->
    <el-dialog
            title="合同信息"
            :visible.sync="contractDialog"
            width="60%">
        <el-form :model="contractForm" label-width="120px">
            <el-form-item label="接收账号">
                <el-input v-model="contractForm.account" readonly></el-input>
            </el-form-item>
            <el-form-item label="接收手机">
                <el-input v-model="contractForm.phone" readonly></el-input>
            </el-form-item>
            <el-form-item label="合同失效时间">
                <el-date-picker
                        v-model="contractForm.expTime"
                        :default-value="getDateTimeStr(5)"
                        type="datetime"
                        placeholder="选择日期时间">
                </el-date-picker>
            </el-form-item>
            <el-form-item label="上传合同">
                <el-upload
                        :action="action"
                        accept=".pdf"
                        limit="1"
                        ref="upload"
                        :headers="getTokenHeader()"
                        :data="getUploadContractData()"
                        :auto-upload="false"
                        :on-success="uploadSuccess"
                >
                    <el-button type="primary">上传合同<i class="el-icon-upload el-icon--right"></i></el-button>
                </el-upload>
            </el-form-item>
        </el-form>
        <span slot="footer" class="dialog-footer">
            <el-button @click="contractDialog = false" size="mini">取 消</el-button>
            <el-button type="primary" @click="handleSendContract" size="mini">
                发送合同
            </el-button>
        </span>

    </el-dialog>
</div>
<script type="text/javascript" src="../../assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="../../assets/js/common.js?v=317"></script>
<script type="text/javascript" src="../../assets/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript" src="../../assets/js/js.cookie.min.js"></script>
<script type="text/javascript" src="../../assets/js/sqjx.js"></script>
<script type="text/javascript" src="../../../assets/js/custom.js"></script>
<script src="../../assets/js/vue.min.js"></script>
<script src="../../assets/js/elementui.js"></script>
<script>
    let that;
    new Vue({
        el: '#app',
        data: function () {
            return {
                action: BASE_URL + '/contract/contract/contractUpload',
                contractForm: {},
                fileName: '',
                dialogVisible: false,
                hireDialog: false,
                newTrainDialog: false,
                contractDialog: false,
                currentRow: '',
                relationList: [],
                eduList: [],
                skillListStr: '',
                workList: [],
                orgList: '',
                page: {
                    list: null,
                    currentPage: 1,
                    limit: 30,
                    tableMaxHeight: 250,
                },
                searchForm: {
                    idNum: '',
                    name: ''
                },
                tableData: [],
                page: {
                    total: 0,
                    currentPage: 1,
                    rows: 10,
                },
                hireTemplateId: '1468734193443950594',
                trainTemplateId: '1468734220170055681',
                hireApproveList: [],
                trainApproveList: [],
                sexOption: [
                    {
                        value: 1,
                        label: '男'
                    },
                    {
                        value: 2,
                        label: '女'
                    }
                ],
                singleOption: [
                    {
                        value: 1,
                        label: '已婚'
                    },
                    {
                        value: 2,
                        label: '未婚'
                    }
                ],
                eduOption: [
                    {
                        value: 1,
                        label: '高中及以下'
                    },
                    {
                        value: 2,
                        label: '大专'
                    },
                    {
                        value: 3,
                        label: '本科'
                    },
                    {
                        value: 4,
                        label: '硕士及以上'
                    },
                ],

            }
        },
        mounted: function () {
            getUrlParam();
            that = this
            this.search();
        },
        methods: {
            viewHealthPdf() {
                window.open(BASE_ANNEX + that.currentRow.healthPdf + '?token=' + Cookies.get('token'));
            },
            getTokenHeader() {
                return {"token": getToken()}
            },
            getUploadContractData() {
                var param = {
                    account: DEVELOP_ACCOUNT,
                    expireTime: this.contractForm.expTime,
                    supplierId: '-',
                    supplierName: this.currentRow.name,
                    contractType: 'L',//劳动合同
                    userName: getUserName(),
                    userCode: getAccount(),
                }
                return param
            },

            handleSendContract() {
                that.$refs.upload.submit();
            },

            uploadSuccess(res) {
                var param = {
                    contractId: res.obj.contractId,//合同编号
                    dpi: "160",//清晰度
                    expireTime: getDateTimeStr('', '', 5),//五天过期
                    forceReadingSeconds: "0",//
                    isAllowChangeSignaturePosition: "1",//拖拽
                    isDrawSignatureImage: "1",//手动签署
                    pageNum: "2",//尾页签署
                    signatureImageName: "",//签名，不填使用系统默认
                    signatureImageRate: "60",//签名大小
                    signaturePositions: [],//位置
                    signer: that.contractForm.account,
                    x: "0.2",//
                    y: "0.89",//
                }
                doPostAsync('/contract/contract/contractSend', param, function (res) {
                    if (res.code == 200) {
                        showAlert('合同已发送，等待签署', 1, function () {
                            that.contractDialog = false;
                        })
                    } else {
                        showAlert(res.msg);
                    }

                })
            },
            chooseFile() {
                var input = document.createElement("input");
                input.type = "file";
                input.click(); //代码执行到这里，本地文件选择框便会打开！
                input.onchange = function () {
                    cbAnnexFile = input.files[0];
                    if (cbAnnexFile.name.indexOf('pdf') == -1) {
                        showAlert('请上传pdf格式文件');
                        return;
                    }
                    that.fileName = cbAnnexFile.name;
                    var formData = new FormData();
                    formData.append("file", cbAnnexFile);
                    var result = uploadFile(formData);
                    if (result.code == 200) {
                        that.currentRow.healthPdf = result.obj.storeName;
                    }
                };
            },
            changeStatus(row) {
                row.lock = row.lock == 1 ? 2 : 1
                that.currentRow = row;
                $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                    if (res1.code == 200) {
                        that.search();
                    }
                })

            },
            handleClose() {
                this.dialogVisible = false
            },
            search: function () {
                var params = this.searchForm;
                params.page = this.page.currentPage;
                params.rows = this.page.rows;
                params.status = 2;
                $.post('/office/hrEmployDetail/queryHrEmployDetailList', params, function (res) {
                    that.tableData = res.obj.rows
                    that.page.total = res.obj.total
                })
            },
            handleOrgChange() {

            },
            handleEdit(row) {
                this.dialogVisible = true;
                this.currentRow = row;
                that.currentRow.trainTime = formatDate(new Date())
                this.getUserRelation();
                this.getUserStudy();
                this.getUserSkill();
                this.getUserWork();
            },
            handleNewTrain(row) {
                this.newTrainDialog = true;
                this.currentRow = row
                that.currentRow.trainTime = formatDate(new Date())
                this.selectMainOrgList();
                this.getTrainFlowTemplate()
            },
            handleContract(row) {
                this.currentRow = row;
                //获取账号信息
                var param = {account: that.currentRow.idNum};
                $.post('/contract/contract/getUser', param, function (res) {
                    if (res.code == 200) {
                        if (res.obj.registerFlag == 5) {
                            //是否有未结束合同
                            $.get('/contract/contract/getNotFinishContract', param, function (response) {
                                if (response.code == 200) {
                                    that.contractDialog = true;
                                    that.contractForm.expTime = getDateTimeStr(5);
                                    that.contractForm.account = res.obj.account;
                                    that.contractForm.phone = res.obj.trustPhone;
                                } else if(response.code==201) {
                                    showAlert('请您先结束上一个合同后再操作');
                                }
                            })
                        } else if (res.obj.registerFlag == 10) {
                            showAlert('该账号正在审核中，请您五分钟后再操作')
                        } else {
                            showAlert('该账号申请失败，请联系管理员')
                        }
                    } else {
                        showAlert(res.msg);
                    }

                })
            },
            handleHire(row) {
                this.hireDialog = true;
                this.currentRow = row;
                that.currentRow.hireTime = formatDate(new Date())
                this.selectMainOrgList();
                this.getHireFlowTemplate()
            },
            getUserRelation() {
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserRelation/getHrUserRelation', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.relationList = res.obj;
                    }
                })
            },
            getUserStudy() {
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserStudy/getHrUserStudy', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.eduList = res.obj;
                    }
                })
            },
            getUserSkill() {
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserSkill/getHrUserSkill', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        var array = []
                        res.obj.forEach(item => {
                            array.push(item.skill)
                        })
                        that.skillListStr = array.join(',')
                    }
                })
            },
            getUserWork() {
                let param = {idNum: this.currentRow.idNum}
                $.get('/office/hrUserWork/getHrUserWork', param, function (res) {
                    if (res.code == 200 && res.obj) {
                        that.workList = res.obj;
                    }
                })
            },
            handleCurrentChange(currentPage) {
                that.page.currentPage = currentPage;
                that.search()
            },
            handleSizeChange() {
            },
            selectMainOrgList() {
                $.get('/office/org/selectMainOrgList', function (res) {
                    that.orgList = res.obj;

                })
            },
            getHireFlowTemplate() {
                var templateId = that.hireTemplateId
                $.get('/office/flowWorkTemplate/startFlowName', {templateId: templateId}, function (res) {
                    that.hireApproveList = res.obj;
                })
            },
            getTrainFlowTemplate() {
                var templateId = that.trainTemplateId
                $.get('/office/flowWorkTemplate/startFlowName', {templateId: templateId}, function (res) {
                    that.trainApproveList = res.obj;
                })
            },
            handleSaveHealthPdf() {
                layer.confirm('确认提交？', function () {
                    that.dialogVisible = false;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function (res1) {
                        if (res1.code == 200) {
                            showAlert('更新员工信息成功', 1, function () {
                                closeDialog();
                                that.handleCreateContractAccount()
                            })
                        }
                    })
                })
            },
            handleSaveHire() {
                var a = that.currentRow.orgId
                var b = that.currentRow.job
                var c = that.currentRow.audition
                if (!a) {
                    showAlert('部门必填')
                    return
                }
                if (!b) {
                    showAlert('岗位必填')
                    return
                }
                if (!c) {
                    showAlert('面试结论必填')
                    return
                }

                layer.confirm('确认提交员工录用审批？', function () {
                    that.hireDialog = false;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function () {
                        $.get('/office/flowWorkTemplate/getHirePreviewNodeList', {
                            templateId: that.hireTemplateId,
                            dynamicOrgId: that.currentRow.orgId,
                            authRoleId: 29
                        }, function (res2) {
                            if (res2.code == 200) {
                                var param = {}
                                param.userId = getUserId();
                                param.userName = getUserName()
                                param.title = '员工入职审批';
                                param.templateId = that.hireTemplateId;
                                param.content = 'apply/hire'
                                param.annex = that.currentRow.idNum;
                                param.touch = BASE_URL + '/office/flowStepInstance/hireCb'
                                $.post('/office/flowWork/addBusinessFlow', param, function (res3) {
                                    if (res3.code == 200) {
                                        var data = {};
                                        data.flowNodes = res2.obj;
                                        data.flowNodes = data.flowNodes.map(item => {
                                            return {orgId: item}
                                        })
                                        data.templateId = that.hireTemplateId
                                        data.instanceId = res3.obj.instanceId;

                                        $.ajax({
                                            url: '/office/flowStepTemplate/addFlowStepTemplate',
                                            data: JSON.stringify(data),
                                            type: 'post',
                                            async: false,
                                            contentType: 'application/json',
                                            success: function (res4) {
                                                if (res4.code == 200) {
                                                    showAlert('流程已送出', 1, function () {
                                                        that.hireDialog = false;
                                                        closeDialog()

                                                    });
                                                }
                                            },
                                            error: function () {
                                                showAlert('服务器内部错误，请联系管理员', 4);
                                            },
                                            complete: function (res) {
                                            }
                                        });
                                    }else{
                                        showAlert(res3.msg,function() {
                                            that.hireDialog = false;
                                            closeDialog()
                                        })
                                    }

                                })
                            }

                        })
                    })

                })
            },
            handleSaveNewTrain() {
                var a = that.currentRow.orgId
                var b = that.currentRow.job
                if (!a) {
                    showAlert('部门必填')
                    return
                }
                if (!b) {
                    showAlert('岗位必填')
                    return
                }
                layer.confirm('确认提交员工培训信息？', function () {
                    that.newTrainDialog = false;
                    $.post('/office/hrEmployDetail/updateHrEmploy', that.currentRow, function () {
                        $.get('/office/flowWorkTemplate/getHirePreviewNodeList', {
                            templateId: that.trainTemplateId,
                            dynamicOrgId: that.currentRow.orgId,
                            authRoleId: 30
                        }, function (res2) {
                            if (res2.code == 200) {
                                var param = {}
                                param.userId = getUserId();
                                param.userName = getUserName()
                                param.title = '入职培训审批';
                                param.templateId = that.trainTemplateId;
                                param.content = 'apply/newTrain'
                                param.annex = that.currentRow.idNum
                                param.touch = BASE_URL + '/office/flowStepInstance/trainCb'
                                $.post('/office/flowWork/addBusinessFlow', param, function (res3) {
                                    if (res3.code == 200) {
                                        var data = {};
                                        data.flowNodes = res2.obj;
                                        data.flowNodes = data.flowNodes.map(item => {
                                            return {orgId: item}
                                        })
                                        data.templateId = that.hireTemplateId
                                        data.instanceId = res3.obj.instanceId;

                                        $.ajax({
                                            url: '/office/flowStepTemplate/addFlowStepTemplate',
                                            data: JSON.stringify(data),
                                            type: 'post',
                                            async: false,
                                            contentType: 'application/json',
                                            success: function (res4) {
                                                if (res4.code == 200) {
                                                    showAlert('流程已送出', 1, function () {
                                                        that.newTrainDialog = false;
                                                        closeDialog()

                                                    });
                                                }
                                            },
                                            error: function () {
                                                showAlert('服务器内部错误，请联系管理员', 4);
                                            },
                                            complete: function (res) {
                                            }
                                        });
                                    }else{
                                        showAlert(res3.msg,function() {
                                            that.hireDialog = false;
                                            closeDialog()
                                        })
                                    }

                                })
                            }

                        })
                    })

                })

            },
            /**
             * 上传健康凭证后生成账号
             */
            handleCreateContractAccount() {
                var param = {};
                param.supplierId = supplierId;
                param.supplierName = '宿迁南钢金鑫轧钢有限公司';
                param.supplierType = 3;//普通员工
                param.userType = 1;
                param.account = that.currentRow.idNum;
                param.identityNum = that.currentRow.idNum
                param.trustName = that.currentRow.name
                param.trustPhone = that.currentRow.phone;
                $.post('/contract/contract/addContractUser', param, function (res) {
                    console.log('账号信息', res.msg)
                })

            }
        },
    })
</script>
</body>
</html>
